package com.zx.designpattern.view.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zx.designpattern.R;
import com.zx.designpattern.base.BaseFragment;
import com.zx.designpattern.utils.interfaceforall.FunctionManager;
import com.zx.designpattern.presenter.BasePresenter;

import butterknife.OnClick;


public class OneFragment extends BaseFragment {

    /**
     * 接口名称：最好使用当前类名，保证唯一性！
     */
    public static final String INTERFACE_NAME = OneFragment.class.getName();

    @OnClick(R.id.btn1)
    void clickBtn1(View view) {
        //触发已经增加的接口
        FunctionManager.getInstance().invokeFunctionNoParamNoResult(INTERFACE_NAME);
    }


    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    private String mParam1;
    private String mParam2;


    public static OneFragment newInstance(String param1, String param2) {
        OneFragment fragment = new OneFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        Log.e(TAG, "------onAttach-----");
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
        Log.e(TAG, "------onCreate-----");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.e(TAG, "------onCreateView-----");
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.e(TAG, "------onActivityCreated-----");
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.e(TAG, "------onResume-----");
    }

    @Override
    public void onStart() {
        super.onStart();
        Log.e(TAG, "------onStart-----");
    }

    @Override
    public void onStop() {
        super.onStop();
        Log.e(TAG, "------onStop-----");
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.e(TAG, "------onDestroyView-----");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.e(TAG, "------onDestroy-----");
    }

    @Override
    public void onDetach() {
        super.onDetach();
        Log.e(TAG, "------onDetach-----");
    }

    @Override
    protected int getRootViewId() {
        return R.layout.fragment_one;
    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }


    @Override
    public void showView(int code, Object data) {

    }
}
